<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_whats_new.php 6128 2007-04-08 04:53:32Z birdbrain $
 */
   $zc_show_featured = true;
   $title = 'Products';
  $content_featured_index ='';
  $content = "";
  
   $random_whats_new_sidebox_product_query = "select p.products_id, p.products_image,  p.products_quantity,  p.products_image_num, pd.products_name,
                                       p.master_categories_id
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED3 . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id
                           and p.products_id = pd.products_id
                           and p.products_status = 1
                           and f.status = 1
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
						   
//echo $random_whats_new_sidebox_product_query;
//  $random_whats_new_sidebox_product = zen_random_select($random_whats_new_sidebox_product_query);
  $random_whats_new_sidebox_product = $db->ExecuteRandomMulti($random_whats_new_sidebox_product_query, 9);
  
  $whats_new_box_counter = 0;
  while (!$random_whats_new_sidebox_product->EOF) {
    $whats_new_box_counter++;
	
	$product_img_url ="";
	$product_id = $random_whats_new_sidebox_product->fields['products_id'];
	$product_img_url = DIR_WS_PRO_MIDDLE. $random_whats_new_sidebox_product->fields['products_image'].'.jpg';
	
	
    $whats_new_price = zen_get_products_display_price($product_id);
	$content_featured_index .= '<li>';
    $content_featured_index .= '<div class="imglink"><a href="' . zen_href_link(zen_get_info_page($product_id), 'cPath=' . zen_get_generated_category_path_rev($random_whats_new_sidebox_product->fields['master_categories_id']) . '&products_id=' . $product_id) . '">' . zen_image($product_img_url, $random_whats_new_sidebox_product->fields['products_name']) . '</a></div>';
    $content_featured_index .= '<a href="' . zen_href_link(zen_get_info_page($product_id), 'cPath=' . zen_get_generated_category_path_rev($random_whats_new_sidebox_product->fields['master_categories_id']) . '&products_id=' . $product_id) . '">' . $random_whats_new_sidebox_product->fields['products_name'] . '</a><br />';
    $content_featured_index .= '<span class="red fl price">' . $whats_new_price . '</span><span class="fl cart">';
	
	if ($random_whats_new_sidebox_product->fields['products_quantity'] > 0) {
		$content_featured_index .= '<a href="' . zen_href_link(zen_get_info_page($product_id),'cPath='.zen_get_generated_category_path_rev($_GET['cPath']).'&products_id='.$product_id.'&action=buy_now') . '" class="buttonAddCartsmall" title="Add To Cart">Add To Cart</a>';
    }else{
		$content_featured_index .= '<img src="images/soldout.gif" alt="Sold Out" />';
	}
	$content_featured_index .= '</span>';
          
    $content_featured_index .= '</li>';
	
    $random_whats_new_sidebox_product->MoveNextRandom();
  }

?>
